home *** CD-ROM | disk | FTP | other *** search
- Path: library.erc.clarkson.edu!rpi!not-for-mail
- From: wcowley@cftnet.com (Wes Cowley)
- Newsgroups: comp.lang.c++.moderated,comp.lang.c++
- Subject: Re: Simple inheritance Q
- Followup-To: comp.lang.c++.moderated,comp.lang.c++
- Date: 28 Feb 1996 13:11:32 -0000
- Organization: CFTnet
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: devitto@ferndown.ate.slb.com
- Message-ID: <4h1ka4$7qk@netlab.cs.rpi.edu>
- References: <4gumo0$hta@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
- X-Original-Date: 28 Feb 1996 10:11:20 GMT
-
- Eric Simon (erics@access2.digex.net) wrote:
- : 1. Animal *p;
- : 2. Cat a(args);
- : 3. p = &a;
- :
- : Now, if I define
- : class Cat:Animal{...
- :
- : then I get the error in line 3:
- : Can not convert Cat * to Animal *
- :
- : But if I define
- : class Cat:public Animal{...
- :
- : everything is fine.
- :
- : Can anyone tell me why?
-
- Inheritance defaults to private, which essentially means that if you use:
-
- class Cat : Animal { ...
-
- code outside your Cat class has no way of knowing that Cat inherits from
- Animal and cannot use the implicit conversion from Cat* to Animal*.
-
- Wes
-
- [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
- [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-